<?php echo $this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?php echo $this->headTitle() ?>
    <?php echo $this->headLink() ?>
    <?php echo $this->headScript() ?>
    <?php $baseUrl = Config::getBasePath(); ?>
</head>

<body>
    <div id="Panel" class="sticky">
        <?php
        /*
						NOTE: Temporarily disabled version notification to avoid confusion,
						Users can check current version in Settings > Status.
						*/
        //echo $this->versionNotify();
        $sss = $this->SourceSwitchStatus();
        $scs = $this->SourceConnectionStatus();
        ?>
        <?php echo $this->partial('partialviews/header.phtml', array(
            "live_dj_switch" => $sss['live_dj'],
            "live_dj_connection" => $scs['live_dj'],
            "master_dj_switch" => $sss['master_dj'],
            "master_dj_connection" => $scs['master_dj'],
            "scheduled_play_switch" => $sss['scheduled_play']
        )) ?>
        <?php $partial = array('menu.phtml', 'default');
        $this->navigation()->menu()->setPartial($partial); ?>


        <script type="text/javascript">
            var schedulePreLoaded = <?php
                                    //Awful hack to speed up loading - Embed the schedule in the response so that the dashboard
                                    //doesn't have to make a separate AJAX request to get this data.
                                    ScheduleController::printCurrentPlaylistForEmbedding();
                                    ?>;
            //The DOM elements that these calls depend on exist by this point:
            parseItems(schedulePreLoaded.entries);
            parseSourceStatus(schedulePreLoaded.source_status);
            parseSwitchStatus(schedulePreLoaded.switch_status);
        </script>
    </div>

    <div id="media_type_nav">
        <!-- class="content-pane" -->
        <div class="btn-group">
            <ul class="dropdown-menu">
                <li id="new-playlist">
                    <a href="#"><?php echo _("Playlist") ?></a>
                </li>
                <li id="new-smart-block">
                    <a href="#"><?php echo _("Smart Block") ?></a>
                </li>
                <li id="new-webstream">
                    <a href="#"><?php echo _("Webstream") ?></a>
                </li>
            </ul>
            <a href="<?php echo Config::getBasePath() . 'plupload' ?>">
                <button id="add_media_btn" class="btn btn-small dashboard-btn btn-new">
                    <span><?php echo _("Upload") ?></span>
                </button>
            </a>
        </div>

        <div class="media_type_selector top-link" data-selection-id="<?php echo MediaType::getDefault(); ?>">
            <a href="<?php echo Config::getBasePath() . 'showbuilder#' ?>">
                <i class='icon-home icon-white'></i>
                <?php echo _("Dashboard") ?>
            </a>
        </div>
        <?php $subnavPrefix = "/showbuilder";
        require_once APPLICATION_PATH . "/views/scripts/partialviews/dashboard-sub-nav.php"; ?>
        <div class="media_type_selector dashboard_sub_nav" data-selection-id="<?php echo MediaType::PODCAST ?>">
            <a href="<?php echo $subnavPrefix; ?>#podcasts">
                <span class="selector-name"><i class='icon-headphones icon-white'></i><?php echo _("Podcasts") ?></span>
            </a>
        </div>

        <hr style="margin-left: 5px; margin-right: 5px">
        <div id="nav">
            <?php echo $this->navigation()->menu(); ?>
        </div>

        <script>
            <?php
            $partitions = Application_Model_Systemstatus::GetDiskInfo();
            $status = new StdClass;
            $disk = $partitions[0];
            $used = $disk->totalSpace - $disk->totalFreeSpace;
            $total = $disk->totalSpace;
            echo "var remainingDiskSpace = " . $disk->totalFreeSpace . ";";
            ?>
        </script>
        <div id="disk_usage">
            <!--<div style="padding-bottom: 2px;">Disk Usage</div>-->
            <div class="disk_usage_progress_bar"></div>
            <div class="disk_usage_percent_in_use"><?php echo sprintf("%01.1fGB of %01.1fGB", $used / pow(2, 30), $total / pow(2, 30)); ?></div>
            <div class="disk_usage_used" style="width:<?php echo sprintf("%01.1f%%", min(100, $used / $total * 100)) ?>;"></div>

            <!--<div style="margin-top: 15px; font-size: 12px;">
            <?php //echo sprintf("%01.1fGB of %01.1fGB", $used/pow(2, 30), $total/pow(2, 30));
            ?>
        </div>-->

        </div>

    </div>

    <?php $hint = Application_Common_UsabilityHints::getUsabilityHint(); ?>
    <div class="usability_hint <?php if ($hint == "") {
                                    echo "hidden";
                                } ?>"><?php echo $hint; ?></div>

    <div class="wrapper <?php if (isset($this->layout()->parent_page)) echo "wrapper_panel"; ?>" id="content">
        <?php echo $this->layout()->content ?>
    </div>
    <?php if (isset($this->layout()->parent_page)) { ?>
        <div id="sub-menu">
            <h3><?php //parent_page is passed in from controller
                echo _($this->layout()->parent_page); ?></h3>
            <hr>
            <?php
            $page = $this->navigation()->findOneBy('title', $this->layout()->parent_page);
            echo $this->navigation()->menu()->render($page);
            ?>
        </div>
    <?php } ?>

    <script id="tmpl-pl-cues" type="text/template">
        <div class="waveform-cues">
  <div class="playlist-time-scale"></div>
  <div class="playlist-tracks"></div>
  <div class="playlist-controls">
	<a class="btn btn-small btn_play"><i class="icon-play icon-white"></i><?php echo _("Play"); ?></a>
    <a class="btn btn-small btn_stop"><i class="icon-stop icon-white"></i><?php echo _("Stop"); ?></a>
	<label class="audio audio_pos">00:00:00.0</label>
  </div>
  <div class="set-cue">
	<label for="editor-cue-in"><?php echo _("Cue In"); ?></label>
    <input type="text" class="audio_start">
    <input type="button" class="btn btn-small set-cue-in" value="<?php echo _("Set Cue In"); ?>">
    <label class="audio editor-cue-in">00:00:00.0</label>
    <span style="display:none" class="cue-in-error"></span>
  </div>
  <div class="set-cue">
    <label for="editor-cue-out"><?php echo _("Cue Out"); ?></label>
    <input type="text" class="audio_end">
    <input type="button" class="btn btn-small set-cue-out" value="<?php echo _("Set Cue Out"); ?>">
    <label class="audio editor-cue-out">00:00:00.0</label>
    <span style="display:none" class="cue-out-error"></span>
  </div>
</div>
</script>

    <script id="tmpl-pl-fades" type="text/template">
        <div class="waveform-fades">
  <div class="playlist-time-scale"></div>
  <div class="playlist-tracks"></div>
  <div class="playlist-controls left-floated">
    <a class="btn btn-small btn_play"><i class="icon-play icon-white"></i><?php echo _("Play"); ?></a>
    <a class="btn btn-small btn_stop"><i class="icon-stop icon-white"></i><?php echo _("Stop"); ?></a>
	<label class="audio audio_pos">00:00:00.0</label>
  </div>
  <div class="set-fade left-floated">
     <a type="button" class="btn btn-small btn_cursor" data-state="cursor"><?php echo _("Cursor"); ?></a>
     <a type="button" class="btn btn-small btn_fadein" data-state="fadein"><?php echo _("Fade In"); ?></a>
     <a type="button" class="btn btn-small btn_fadeout" data-state="fadeout"><?php echo _("Fade Out"); ?></a>
  </div>
</div>
</script>

    <?php
    // Show users the What's New dialog if they haven't seen it yet
    // TODO: If you're updating this, be sure to update defaultdata! (Suboptimal, is there a better way?)
    if (!Application_Model_Preference::getWhatsNewDialogViewed()) {
    ?>
        <div id="whatsnew">
            <div>
                <div id="whatsnew_video">
                    <iframe width="560" height="315" src="<?php echo UI_REVAMP_EMBED_URL ?>" frameborder="0" allowfullscreen></iframe>
                </div>
                <h2><?php echo _("Welcome to LibreTime"); ?></h2>
                <p><?php echo _("LibreTime is free software for radio stations built by a community.
                You can find out more information at LibreTime.org. We are built as a fork of Airtime.
                If you have any questions you can also go to https://discourse.libretime.org and ask them."); ?></p>
            </div>
            <button id="whatsnew_close" class="btn btn-new">OK, got it!</button>
        </div>
        <script>
            $(document).ready(function() {
                var whatsnew = $("#whatsnew");
                whatsnew.dialog({
                    title: $.i18n._("Welcome to the Libretime!"),
                    width: "auto",
                    height: "auto",
                    modal: true,
                    resizable: false,
                    close: function() {
                        $(this).dialog('destroy').remove();
                    }
                });

                $("#whatsnew_close").on("click", function() {
                    whatsnew.dialog("close");
                });
            });
        </script>
    <?php
        Application_Model_Preference::setWhatsNewDialogViewed(true);
    }
    ?>

    <div id="fb-root"></div>


</body>

</html>
